//转化省标数据内容
var pageii = null;
var baseURL = "../../";
Vue.filter('formatterBLevel', function (value) {
    switch (value) {
        case "0":
            return "国标";
            break;
        case "1":
            return "省标";
            break;
        case "2":
            return "市标";
            break;
        default:
            return "县标";
    }
});

Vue.filter('formatterTime', function (value) { // 时间戳转时间
    var date = new Date(value);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
    Y = date.getFullYear() + '-';
    M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
    D = date.getDate() + ' ';
    h = date.getHours() + ':';
    m = date.getMinutes() + ':';
    s = date.getSeconds();
    return Y + M + D;
})

var vm = new Vue({
    el: '#rrapp',
    data: {
        showList: true,
        title: null,
        firstAddShowFlag: true,
        addFirstKindDetailData: {},
        firstKindSubmitForm: {
            levelNum: '1',
            questionDescription: '',
            isGenerateStandardTemplate: '0',
            parentId: '0'
        }
    },
    mounted() {
        this.getAddFirstData()
    },
    methods: {
        //取消
        cancelFirstAdd: function () {
            parent.layer.close(parent.pageii);
        },
        saveFirstKind: function () {
            layer.confirm("是否确定添加大类？", function (index) {
                let url = 'business/supervisestandard/save';
                let params = vm.firstKindSubmitForm;
                // params.isGenerateStandardTemplate = 1;//是否生成标准模板 0 不生成 1 生成， 做个操作
                // params.deptId = vm.rightKindDetailData.deptId
                $.ajax({
                    type: "POST",
                    url: baseURL + url,
                    contentType: "application/json",
                    data: JSON.stringify(params),
                    success: function (res) {

                        if (res.code === '0') {
                            //请求成功刷新页面数据
                            parent.layer.close(parent.pageii);
                            parent.vm.getlistData();
                            parent.vm.hideAll();
                        } else {
                            alert(res.msg);
                        }
                        layer.close(index);
                    }
                });
            });
        },
        getAddFirstData: function () {
            let url = 'business/supervisestandard/getNextObjectInfo';
            $.ajax({
                type: "POST",
                url: baseURL+url,
                data: {
                    level: 1
                },
                // contentType: "application/json",
                success: function (res) {
                    if (res.code === '0') {
                        vm.addFirstKindDetailData = res.superviseStandard;
                    } else {
                        alert(res.msg);
                    }
                }
            });
        }

    }
});